package spacewar2.objects;

import spacewar2.powerups.SpacewarPowerup;
import spacewar2.utilities.Position;

/**
 * All weapons should subclass this main weapon class.
 * 
 * @author amy
 */
abstract public class SpacewarWeapon extends SpacewarObject implements SpacewarPowerup {
	/**
	 * The amount of damage this weapon inflicts
	 */
	int damage;
	
	/**
	 * The cost to fire this weapon
	 */
	int costToUse;
	
	/**
	 * The ship that fired this weapon
	 */
	Ship firingShip;
	
	/**
	 * Make a new weapon with the requiremed information
	 * 
	 * @param mass
	 * @param radius
	 * @param position
	 * @param damage
	 * @param costToUse
	 * @param teamName Needed to ensure this weapon belongs to the ship that fired it
	 * @param firingShipId Needed to ensure this weapon belongs to the ship that fired it
	 */
	public SpacewarWeapon(int mass, int radius, Position position, int damage, int costToUse, Ship firingShip) {
		super(mass, radius, position);
		this.damage = damage;
		this.costToUse = costToUse;
		this.firingShip = firingShip;
	}
	
	/**
	 * Returns the damage for the weapon
	 * @return
	 */
	public int getDamage() {
		return damage;
	}

	/**
	 * Return the cost for using the weapon
	 * @return
	 */
	public int getCostToUse() {
		return costToUse;
	}
	
	/**
	 * Get the ship that fired this weapon
	 * @return
	 */
	public Ship getFiringShip() {
		return firingShip;
	}

	/**
	 * Set the firing ship (should only be inside the simulator)
	 * @param firingShip
	 */
	public void setFiringShip(Ship firingShip) {
		this.firingShip = firingShip;
	}
	
	
	/**
	 * Return true if the weapon can be fired by the ship and team and false otherwise
	 * 
	 * @param teamName
	 * @param shipId
	 * @return
	 */
	public boolean isValidWeapon(Ship ship) {
		if (firingShip.equals(ship)) {
			return true;
		} 
		return false;
	}
	
}
